package com.sciencep.pro.admin.system.controller;

import com.sciencep.pro.common.domain.ResponseResult;
import com.sciencep.pro.core.domain.dto.calendarinfo.CalendarInfoTO;
import com.sciencep.pro.core.domain.entity.CalendarInfo;
import com.sciencep.pro.core.service.ICalendarInfoService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/calendar")
public class CalendarController {

    @Autowired
    ICalendarInfoService calendarInfoService;

    @GetMapping(value = "/selectByYear")
    @ApiOperation(value = "查看日历")
    public ResponseResult<Object> selectByYear(CalendarInfoTO calendarInfoTO){
        return calendarInfoService.selectByYear(calendarInfoTO);
    }

    @PostMapping(value = "/saveCalendar")
    @ApiOperation(value = "更新日历")
    public ResponseResult<CalendarInfo> saveCalendar(@RequestBody List<CalendarInfoTO> calendarInfoTOList){
        return calendarInfoService.saveCalendar(calendarInfoTOList);
    }

    @GetMapping(value = "/createCalendar")
    @ApiOperation(value = "手动生成日历(没有节假日)")
    public ResponseResult<Object> createCalendar(@RequestParam Integer year) {
        return calendarInfoService.createCalendar(year);
    }

}
